import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { FormattedMessage } from 'react-intl'
import { InputItem, NoticeBar ,Icon} from 'antd-mobile'
import { hashHistory } from 'react-router'
import { GuadanListItem } from './'
import { helper, myFetch, config } from '../utils'


class GuadanList extends Component {
  state = {
    dataList: []
  }
  onFetchTradeireki = () => {
    const options = {
      method: 'POST',
      body: JSON.stringify({
        PGNO: 1,
        SKKB: 1,
      })
    }
    myFetch(`${config.rootApi}/mAvailorderlist`, options, true)
    .then((rs) => {
      console.log(rs, 'rs')
      if (rs && rs.statusCode == 0) {
        let data = rs.dataInfoAvailOrder.dataListAvailOrders
        this.setState({
          dataList: data
        })
      }
    })
  }
  componentDidMount() {
    this.onFetchTradeireki()
  }
  onCancel = (flag) => {
    //console.log(flag, 1)
    if (flag) {
      this.onFetchTradeireki()
    }
  }
  render() {
    const { dataList } = this.state
    console.log(dataList)
    return (
      <ul className="guadan-page">
       {
        dataList.map((val, index) => {
          return <GuadanListItem
            data={val}
            key={index}
            onCancel={this.onCancel}
          />
        })
       }   
      </ul>
    )
  }
}

export default GuadanList